<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="../js/underscore.js"></script>
    <script>
        function Person(name, age) {
            this.name = name;
            this.age = age;
        }
        Person.prototype.location = 'Chengdu';
        var xiaoming = new Person('xiaoming', 12);
        // 获取对象所有key，不包含原型链的key
        console.log('_.keys(xiaoming) = ' + JSON.stringify(_.keys(xiaoming)));
        // 获取对象所有key，包含原型链的key
        console.log('_.allKeys(xiaoming) = ' + JSON.stringify(_.allKeys(xiaoming)));
        // 获取对象所有value
        console.log('_.values(xiaoming) = ' + JSON.stringify(_.values(xiaoming)));
        // 对对象进行遍历操作
        console.log('_.mapObject(xiaoming, (value, key) => value + 1; = ' + JSON.stringify(_.mapObject(xiaoming, function (value, key) {
            return value + 1;
        })));
        // 切换键值
        console.log('_.invert(xiaoming) = ' + JSON.stringify(_.invert(xiaoming)));
        // 合并对象
        console.log('_.extend(a, {age: 15}, {age: 88, city: "Beijing"}) = ' + JSON.stringify(_.extend(xiaoming, { age: 15 }, { age: 88, city: 'Beijing' })));
        // 复制对象
        console.log('_.clone(xiaoming) = ' + JSON.stringify(_.clone(xiaoming)));
        var o1 = { name: 'Bob', skills: { Java: 90, JavaScript: 99 } };
        var o2 = { name: 'Bob', skills: { JavaScript: 99, Java: 90 } };
        console.log('o1 === o2 is ' + (o1 === o2));
        // 判断两个对象值是否相等
        console.log('_.isEqual(o1, o2) is ' + _.isEqual(o1, o2));
    </script>
</head>

<body>

</body>

</html>